(function(){
	
	Ext.define('NetShopping.goods.GoodsBaseGridStore',{
		extend:'Ext.data.Store',
		autoLoad: true,
		fields: [
			{name:'id'},
			{name:'goodsName'},
			{name:'goodsCode'},
			{name:'goodsPrice'},
			{name:'goodsUnit'},
			{name:'goodsInfo'},
			{name:'createTime'},
			{name:'isUse'}
		],
		pageSize:20,
	    proxy: {
	        type: 'ajax',
	        url: '/goods/queryGoodsBasePage.do',
	        reader: {
	            type: 'json',
	            root: 'objectList',
	            totalProperty:'allCount'
	        }
	    }
	});
	
	Ext.define('NetShopping.goods.GoodsBaseGrid',{
		extend:'AppView.base.BaseGrid',
		alias:'widget.goodsbasegrid',
		columns: [
	        { text: '商品名称',  dataIndex: 'goodsName' ,flex: 1 },
	        { text: '商品编码', dataIndex: 'goodsCode', flex: 1 },
	        { text: '商品价格', dataIndex: 'goodsPrice', flex: 1 },
	        { text: '商品单位', dataIndex: 'goodsUnit', flex: 1 },
	        { text: '商品描述', dataIndex: 'goodsInfo', flex: 1 },
	        { text: '发布时间', dataIndex: 'createTime' ,flex: 1, 
				renderer:Renderer.DateRenderer('Y-m-d H:i:s')
	        }
	    ],
	    dockedItems: [{
	        xtype: 'toolbar',
	        dock: 'top',
	        items: [{
				xtype:'textfield',
				margin:'0 0 0 5',
				fieldLabel:'商品名称',
				labelWidth:60,
				name:'goodsName'
		    },{
                text: '检索',
                icon: 'resources/button/search.png',
                handler:function(){
                	var grid = this.up('grid');
                	grid.getStore().getProxy().extraParams.goodsName = grid.down('[name=goodsName]').getValue();
                	grid.getStore().loadPage(1);
                }
            },
            {
                text: '重置',
                icon: 'resources/button/set.png',
                handler:function(){
                	this.up('toolbar').down('[name=goodsName]').setValue('');
                }
            }]
	    }],
//	    gridTbar:[
//			{
//				xtype: 'button',
//				icon:'resources/button/set.png',
//				text: '加入购物车'
//			}
//		],
	    editWin:'NetShopping.goods.GoodsBaseWin',
	    gridStore:'NetShopping.goods.GoodsBaseGridStore',
	    moduleUrl:'/goods',
	    initComponent:function(){
			this.callParent();
	    }
	})
})()

